<!DOCTYPE HTML>
<html lang="zh-CN">


<head><meta name="generator" content="Hexo 3.9.0">
    <meta charset="utf-8">
    <meta name="keywords" content="Apache Commons Lang之StringUtils, 闪烁之狐, Blinkfox">
    <meta name="description" content="
码农不识Apache，码尽一生也枉然。

判断空字符串isEmpty(CharSequence cs)判断是否是空字符串，代码示例：
StringUtils.isEmpty(null)      = true
StringUtils.is">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Apache Commons Lang之StringUtils | 闪烁之狐</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">
    <style type="text/css">
        
        code[class*="language-"], pre[class*="language-"] {
            white-space: pre !important;
        }
        
    </style>

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>

<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">闪烁之狐</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>首页</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>标签</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>分类</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/archives" class="waves-effect waves-light">
            
            <i class="fa fa-archive"></i>
            
            <span>归档</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>关于</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/friends" class="waves-effect waves-light">
            
            <i class="fa fa-address-book"></i>
            
            <span>友情链接</span>
        </a>
    </li>
    
    <li>
        <a href="#searchModal" class="modal-trigger waves-effect waves-light">
            <i id="searchIcon" class="fa fa-search" title="搜索"></i>
        </a>
    </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">闪烁之狐</div>
        <div class="logo-desc">
            
            从来没有真正的绝境，只有心灵的迷途
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                首页
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                标签
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                分类
            </a>
        </li>
        
        <li>
            <a href="/archives" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-archive"></i>
                
                归档
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                关于
            </a>
        </li>
        
        <li>
            <a href="/friends" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-address-book"></i>
                
                友情链接
            </a>
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fa fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>





<div class="bg-cover pd-header post-cover" style="background-image: url('http://static.blinkfox.com/hexoblog_20180927_string.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        Apache Commons Lang之StringUtils
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }
</style>
<div class="row">
    <div class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/Java/" target="_blank">
                                <span class="chip bg-color">Java</span>
                            </a>
                        
                            <a href="/tags/Apache/" target="_blank">
                                <span class="chip bg-color">Apache</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fa fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/后端/" class="post-category" target="_blank">
                                后端
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                <div class="post-date info-break-policy">
                    <i class="fa fa-calendar-minus-o fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2018-09-27
                </div>

                
                    
                    <div class="info-break-policy">
                        <i class="fa fa-file-word-o fa-fw"></i>文章字数:&nbsp;&nbsp;
                        3.5k
                    </div>
                    

                    
                    <div class="info-break-policy">
                        <i class="fa fa-clock-o fa-fw"></i>阅读时长:&nbsp;&nbsp;
                        17 分
                    </div>
                    
                
				
				
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="fa fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <blockquote>
<p>码农不识Apache，码尽一生也枉然。</p>
</blockquote>
<h2 id="判断空字符串"><a href="#判断空字符串" class="headerlink" title="判断空字符串"></a>判断空字符串</h2><h3 id="isEmpty-CharSequence-cs"><a href="#isEmpty-CharSequence-cs" class="headerlink" title="isEmpty(CharSequence cs)"></a>isEmpty(CharSequence cs)</h3><p>判断是否是空字符串，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">isEmpty</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>      <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isEmpty</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isEmpty</span><span class="token punctuation">(</span><span class="token string">" "</span><span class="token punctuation">)</span>       <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isEmpty</span><span class="token punctuation">(</span><span class="token string">"bob"</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isEmpty</span><span class="token punctuation">(</span><span class="token string">"  bob  "</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="isNotEmpty-CharSequence-cs"><a href="#isNotEmpty-CharSequence-cs" class="headerlink" title="isNotEmpty(CharSequence cs)"></a>isNotEmpty(CharSequence cs)</h3><p>判断是否不是空字符串，与<code>isEmpty(CharSequence cs)</code>相反。</p>
<h3 id="isAnyEmpty-CharSequence…-css"><a href="#isAnyEmpty-CharSequence…-css" class="headerlink" title="isAnyEmpty(CharSequence… css)"></a>isAnyEmpty(CharSequence… css)</h3><p>判断是否含有空字符串，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">isAnyEmpty</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>             <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAnyEmpty</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">"foo"</span><span class="token punctuation">)</span>      <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAnyEmpty</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">"bar"</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAnyEmpty</span><span class="token punctuation">(</span><span class="token string">"bob"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAnyEmpty</span><span class="token punctuation">(</span><span class="token string">"  bob  "</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAnyEmpty</span><span class="token punctuation">(</span><span class="token string">" "</span><span class="token punctuation">,</span> <span class="token string">"bar"</span><span class="token punctuation">)</span>       <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAnyEmpty</span><span class="token punctuation">(</span><span class="token string">"foo"</span><span class="token punctuation">,</span> <span class="token string">"bar"</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="isNoneEmpty-CharSequence…-css"><a href="#isNoneEmpty-CharSequence…-css" class="headerlink" title="isNoneEmpty(CharSequence… css)"></a>isNoneEmpty(CharSequence… css)</h3><p>判断是否都不是空字符串，与<code>isAnyEmpty(CharSequence... css)</code>相反。</p>
<h3 id="isAllEmpty-CharSequence…-css"><a href="#isAllEmpty-CharSequence…-css" class="headerlink" title="isAllEmpty(CharSequence… css)"></a>isAllEmpty(CharSequence… css)</h3><p>判断是否都是空字符串，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">isAllEmpty</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>             <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllEmpty</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>         <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllEmpty</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllEmpty</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">"foo"</span><span class="token punctuation">)</span>      <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllEmpty</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">"bar"</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllEmpty</span><span class="token punctuation">(</span><span class="token string">"bob"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllEmpty</span><span class="token punctuation">(</span><span class="token string">"  bob  "</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllEmpty</span><span class="token punctuation">(</span><span class="token string">" "</span><span class="token punctuation">,</span> <span class="token string">"bar"</span><span class="token punctuation">)</span>       <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllEmpty</span><span class="token punctuation">(</span><span class="token string">"foo"</span><span class="token punctuation">,</span> <span class="token string">"bar"</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="isBlank-CharSequence-cs"><a href="#isBlank-CharSequence-cs" class="headerlink" title="isBlank(CharSequence cs)"></a>isBlank(CharSequence cs)</h3><p>判断是否是“大空字符串”，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">isBlank</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>      <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isBlank</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isBlank</span><span class="token punctuation">(</span><span class="token string">" "</span><span class="token punctuation">)</span>       <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isBlank</span><span class="token punctuation">(</span><span class="token string">"bob"</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isBlank</span><span class="token punctuation">(</span><span class="token string">"  bob  "</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="isNotBlank-CharSequence-cs"><a href="#isNotBlank-CharSequence-cs" class="headerlink" title="isNotBlank(CharSequence cs)"></a>isNotBlank(CharSequence cs)</h3><p>判断是否不是“大空字符串”，与<code>isBlank(CharSequence cs)</code>相反，与<code>isNotEmpty(CharSequence cs)</code>相似。</p>
<h3 id="isAnyBlank-CharSequence…-css"><a href="#isAnyBlank-CharSequence…-css" class="headerlink" title="isAnyBlank(CharSequence… css)"></a>isAnyBlank(CharSequence… css)</h3><p>判断是否有“大空字符串”，与<code>isAnyEmpty(CharSequence... css)</code>相似。</p>
<h3 id="isNoneBlank-CharSequence…-css"><a href="#isNoneBlank-CharSequence…-css" class="headerlink" title="isNoneBlank(CharSequence… css)"></a>isNoneBlank(CharSequence… css)</h3><p>判断是否都不是“大空字符串”，与<code>isAnyBlank(CharSequence... css)</code>相反，与<code>isNoneEmpty(CharSequence... css)</code>相似。</p>
<h3 id="isAllBlank-CharSequence…-css"><a href="#isAllBlank-CharSequence…-css" class="headerlink" title="isAllBlank(CharSequence… css)"></a>isAllBlank(CharSequence… css)</h3><p>判断是否都是“大空字符串”，与<code>isAllEmpty(CharSequence... css)</code>相似。</p>
<h2 id="截取字符串"><a href="#截取字符串" class="headerlink" title="截取字符串"></a>截取字符串</h2><h3 id="trim-String-str"><a href="#trim-String-str" class="headerlink" title="trim(String str)"></a>trim(String str)</h3><p>去除字符串前后的控制符，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>          <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>            <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token string">"     "</span><span class="token punctuation">)</span>       <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">)</span>         <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">trim</span><span class="token punctuation">(</span><span class="token string">"    abc    "</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abc"</span></code></pre>
<h3 id="trimToNull-String-str"><a href="#trimToNull-String-str" class="headerlink" title="trimToNull(String str)"></a>trimToNull(String str)</h3><p>去除字符串前后的控制符，如何是空字符串则转为<code>null</code>，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">trimToNull</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>          <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">trimToNull</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>            <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">trimToNull</span><span class="token punctuation">(</span><span class="token string">"     "</span><span class="token punctuation">)</span>       <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">trimToNull</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">)</span>         <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">trimToNull</span><span class="token punctuation">(</span><span class="token string">"    abc    "</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abc"</span></code></pre>
<h3 id="trimToEmpty-String-str"><a href="#trimToEmpty-String-str" class="headerlink" title="trimToEmpty(String str)"></a>trimToEmpty(String str)</h3><p>去除字符串前后的控制符，如何是<code>null</code>则转为空字符串，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">trimToEmpty</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>          <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">trimToEmpty</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>            <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">trimToEmpty</span><span class="token punctuation">(</span><span class="token string">"     "</span><span class="token punctuation">)</span>       <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">trimToEmpty</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">)</span>         <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">trimToEmpty</span><span class="token punctuation">(</span><span class="token string">"    abc    "</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abc"</span></code></pre>
<h3 id="truncate-String-str-int-maxWidth"><a href="#truncate-String-str-int-maxWidth" class="headerlink" title="truncate(String str, int maxWidth)"></a>truncate(String str, int maxWidth)</h3><p>截断字符串，具有以下特点：</p>
<ul>
<li>如果str字符串的长度小于maxWidth，则直接返回str。</li>
<li>不满足第一条时，则为<code>substring(str, 0, maxWidth)</code>。</li>
<li>如果maxWidth小于0，则抛出IllegalArgumentException。</li>
<li>在任何情况下都不会返回长度大于maxWidth的字符串。</li>
</ul>
<p>代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>       <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>       <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span>         <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"abcd"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"abcdef"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"abcdefg"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"abcdefg"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token keyword">throws</span> an IllegalArgumentException</code></pre>
<h3 id="truncate-String-str-int-offset-int-maxWidth"><a href="#truncate-String-str-int-offset-int-maxWidth" class="headerlink" title="truncate(String str, int offset, int maxWidth)"></a>truncate(String str, int offset, int maxWidth)</h3><p>截断字符串，具有以下特点：</p>
<ul>
<li>如果str字符串的长度小于maxWidth，则直接返回str。</li>
<li>不满足第一条时，则为<code>substring(str, offset, maxWidth)</code>。</li>
<li>如果maxWidth或者offset小于0，则抛出IllegalArgumentException。</li>
<li>在任何情况下都不会返回长度大于maxWidth的字符串。</li>
</ul>
<p>代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghij"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghij"</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"fghij"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"raspberry peach"</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"peach"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abcdefghij"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token keyword">throws</span> an IllegalArgumentException
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MIN_VALUE<span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abcdefghij"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MIN_VALUE<span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MAX_VALUE<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abcdefghijklmno"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MAX_VALUE<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abcdefghijklmno"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"bcdefghijk"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"cdefghijkl"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"defghijklm"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"efghijklmn"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"fghijklmno"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"fghij"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"fgh"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"klm"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MAX_VALUE<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"klmno"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">13</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"n"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">13</span><span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MAX_VALUE<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"no"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">14</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"o"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">14</span><span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MAX_VALUE<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"o"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> <span class="token number">15</span><span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MAX_VALUE<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghijklmno"</span><span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MAX_VALUE<span class="token punctuation">,</span> Integer<span class="token punctuation">.</span>MAX_VALUE<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghij"</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token keyword">throws</span> an IllegalArgumentException
StringUtils<span class="token punctuation">.</span><span class="token function">truncate</span><span class="token punctuation">(</span><span class="token string">"abcdefghij"</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token keyword">throws</span> an IllegalArgumentException</code></pre>
<h3 id="left-String-str-int-len"><a href="#left-String-str-int-len" class="headerlink" title="left(String str, int len)"></a>left(String str, int len)</h3><p>得到一个字符串最左边的len个字符</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">left</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">left</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"ab"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">left</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"abc"</span></code></pre>
<h3 id="right-String-str-int-len"><a href="#right-String-str-int-len" class="headerlink" title="right(String str, int len)"></a>right(String str, int len)</h3><p>同<code>left(String str, int len)</code>相反，从右边截取len个字符。</p>
<h3 id="mid-String-str-int-pos-int-len"><a href="#mid-String-str-int-pos-int-len" class="headerlink" title="mid(String str, int pos, int len)"></a>mid(String str, int pos, int len)</h3><p>得到一个字符串中间的len个字符。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">mid</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"ab"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">mid</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">mid</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"c"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">mid</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">mid</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"ab"</span></code></pre>
<h3 id="substringBefore-String-str-String-separator"><a href="#substringBefore-String-str-String-separator" class="headerlink" title="substringBefore(String str, String separator)"></a>substringBefore(String str, String separator)</h3><p>得到一个字符串第一个分隔符字符串之前的字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">substringBefore</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">substringBefore</span><span class="token punctuation">(</span><span class="token string">"abcba"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"a"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">substringBefore</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"c"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"ab"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">substringBefore</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"d"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">substringBefore</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">substringBefore</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"abc"</span></code></pre>
<h3 id="substringAfter-String-str-String-separator"><a href="#substringAfter-String-str-String-separator" class="headerlink" title="substringAfter(String str, String separator)"></a>substringAfter(String str, String separator)</h3><p>同<code>substringBefore(String str, String separator)</code>相反。得到一个字符串第一个分隔符字符串之后的字符串。</p>
<h3 id="substringBetween-String-str-String-open-String-close"><a href="#substringBetween-String-str-String-open-String-close" class="headerlink" title="substringBetween(String str, String open, String close)"></a>substringBetween(String str, String open, String close)</h3><p>得到一个字符串两个字符串之间字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">substringBetween</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>          <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">substringBetween</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">"]"</span><span class="token punctuation">)</span>         <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">substringBetween</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">"["</span><span class="token punctuation">,</span> <span class="token string">"]"</span><span class="token punctuation">)</span>        <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">substringBetween</span><span class="token punctuation">(</span><span class="token string">"yabcz"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">substringBetween</span><span class="token punctuation">(</span><span class="token string">"yabcz"</span><span class="token punctuation">,</span> <span class="token string">"y"</span><span class="token punctuation">,</span> <span class="token string">"z"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">substringBetween</span><span class="token punctuation">(</span><span class="token string">"yabczyabcz"</span><span class="token punctuation">,</span> <span class="token string">"y"</span><span class="token punctuation">,</span> <span class="token string">"z"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"abc"</span></code></pre>
<h3 id="substringBetween-String-str-String-tag"><a href="#substringBetween-String-str-String-tag" class="headerlink" title="substringBetween(String str, String tag)"></a>substringBetween(String str, String tag)</h3><p>是<code>substringBetween(String str, String open, String close)</code>的特殊情形。得到一个字符串中同一个字符串之间的字符串。</p>
<h2 id="比较字符串"><a href="#比较字符串" class="headerlink" title="比较字符串"></a>比较字符串</h2><h3 id="equals-CharSequence-cs1-CharSequence-cs2"><a href="#equals-CharSequence-cs1-CharSequence-cs2" class="headerlink" title="equals(CharSequence cs1, CharSequence cs2)"></a>equals(CharSequence cs1, CharSequence cs2)</h3><p>判断两字符串相等，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> null<span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"ABC"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="equalsIgnoreCase-CharSequence-str1-CharSequence-str2"><a href="#equalsIgnoreCase-CharSequence-str1-CharSequence-str2" class="headerlink" title="equalsIgnoreCase(CharSequence str1, CharSequence str2)"></a>equalsIgnoreCase(CharSequence str1, CharSequence str2)</h3><p>判断两字符串相等，忽略大小写，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">equalsIgnoreCase</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> null<span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsIgnoreCase</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"ABC"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span></code></pre>
<h3 id="equalsAny-CharSequence-string-CharSequence…-searchStrings"><a href="#equalsAny-CharSequence-string-CharSequence…-searchStrings" class="headerlink" title="equalsAny(CharSequence string, CharSequence… searchStrings)"></a>equalsAny(CharSequence string, CharSequence… searchStrings)</h3><p>比较一个字符串是否与其后的某个字符串相等，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">equalsAny</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token punctuation">(</span>CharSequence<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span> null<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAny</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> null<span class="token punctuation">,</span> null<span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAny</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"def"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAny</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token string">"def"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAny</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"def"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAny</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"ABC"</span><span class="token punctuation">,</span> <span class="token string">"DEF"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="equalsAnyIgnoreCase-CharSequence-string-CharSequence…searchStrings"><a href="#equalsAnyIgnoreCase-CharSequence-string-CharSequence…searchStrings" class="headerlink" title="equalsAnyIgnoreCase(CharSequence string, CharSequence…searchStrings)"></a>equalsAnyIgnoreCase(CharSequence string, CharSequence…searchStrings)</h3><p>比较一个字符串是否与其后的某个字符串相等，忽略大小写，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">equalsAnyIgnoreCase</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token punctuation">(</span>CharSequence<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span> null<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAnyIgnoreCase</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> null<span class="token punctuation">,</span> null<span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAnyIgnoreCase</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"def"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAnyIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token string">"def"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAnyIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"def"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">equalsAnyIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"ABC"</span><span class="token punctuation">,</span> <span class="token string">"DEF"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span></code></pre>
<h3 id="compare-String-str1-String-str2"><a href="#compare-String-str1-String-str2" class="headerlink" title="compare(String str1, String str2)"></a>compare(String str1, String str2)</h3><p>比较两字符串的大小，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">compare</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> null<span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compare</span><span class="token punctuation">(</span>null <span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">)</span>   <span class="token operator">&lt;</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compare</span><span class="token punctuation">(</span><span class="token string">"a"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>    <span class="token operator">></span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compare</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compare</span><span class="token punctuation">(</span><span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">)</span>     <span class="token operator">&lt;</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compare</span><span class="token punctuation">(</span><span class="token string">"b"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">)</span>     <span class="token operator">></span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compare</span><span class="token punctuation">(</span><span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"B"</span><span class="token punctuation">)</span>     <span class="token operator">></span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compare</span><span class="token punctuation">(</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span>  <span class="token operator">&lt;</span> <span class="token number">0</span></code></pre>
<h3 id="compareIgnoreCase-String-str1-String-str2"><a href="#compareIgnoreCase-String-str1-String-str2" class="headerlink" title="compareIgnoreCase(String str1, String str2)"></a>compareIgnoreCase(String str1, String str2)</h3><p>比较两字符串的大小，忽略大小写，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> null<span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span>null <span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">)</span>   <span class="token operator">&lt;</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"a"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>    <span class="token operator">></span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"ABC"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">)</span>     <span class="token operator">&lt;</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"b"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">)</span>     <span class="token operator">></span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"B"</span><span class="token punctuation">)</span>     <span class="token operator">&lt;</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"A"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">)</span>     <span class="token operator">&lt;</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">compareIgnoreCase</span><span class="token punctuation">(</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"ABC"</span><span class="token punctuation">)</span>  <span class="token operator">&lt;</span> <span class="token number">0</span></code></pre>
<h2 id="查找元素"><a href="#查找元素" class="headerlink" title="查找元素"></a>查找元素</h2><h3 id="indexOf-CharSequence-seq-int-searchChar"><a href="#indexOf-CharSequence-seq-int-searchChar" class="headerlink" title="indexOf(CharSequence seq, int searchChar)"></a>indexOf(CharSequence seq, int searchChar)</h3><p>查找某个字符在字符串中第一次出现时的索引位置，代码示例：</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">'a'</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">2</span></code></pre>
<h3 id="indexOf-CharSequence-seq-CharSequence-searchSeq"><a href="#indexOf-CharSequence-seq-CharSequence-searchSeq" class="headerlink" title="indexOf(CharSequence seq, CharSequence searchSeq)"></a>indexOf(CharSequence seq, CharSequence searchSeq)</h3><p>同<code>indexOf(CharSequence seq, int searchChar)</code>相似。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"c"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token number">2</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"ab"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">1</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token number">0</span></code></pre>
<h3 id="indexOf-final-CharSequence-seq-final-CharSequence-searchSeq-final-int-startPos"><a href="#indexOf-final-CharSequence-seq-final-CharSequence-searchSeq-final-int-startPos" class="headerlink" title="indexOf(final CharSequence seq, final CharSequence searchSeq, final int startPos)"></a>indexOf(final CharSequence seq, final CharSequence searchSeq, final int startPos)</h3><p>同<code>indexOf(CharSequence seq, int searchChar)</code>相似。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token number">2</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">1</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token number">5</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">,</span> <span class="token number">9</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">2</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"aabaabaa"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token number">2</span>
StringUtils<span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token number">9</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token number">3</span></code></pre>
<h3 id="indexOfIgnoreCase-CharSequence-str-CharSequence-searchStr"><a href="#indexOfIgnoreCase-CharSequence-str-CharSequence-searchStr" class="headerlink" title="indexOfIgnoreCase(CharSequence str, CharSequence searchStr)"></a>indexOfIgnoreCase(CharSequence str, CharSequence searchStr)</h3><p>同<code>indexOf(CharSequence seq, int searchChar)</code>相似,忽略大小写。</p>
<h3 id="lastIndexOf-CharSequence-seq-int-searchChar"><a href="#lastIndexOf-CharSequence-seq-int-searchChar" class="headerlink" title="lastIndexOf(CharSequence seq, int searchChar)"></a>lastIndexOf(CharSequence seq, int searchChar)</h3><p>同<code>indexOf(CharSequence seq, int searchChar)</code>相似，从后面开始查找。</p>
<h3 id="contains-CharSequence-seq-CharSequence-searchSeq"><a href="#contains-CharSequence-seq-CharSequence-searchSeq" class="headerlink" title="contains(CharSequence seq, CharSequence searchSeq)"></a>contains(CharSequence seq, CharSequence searchSeq)</h3><p>判断某字符串是否包含某子字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">contains</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>      <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">contains</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">contains</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">contains</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"z"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="containsIgnoreCase-CharSequence-str-CharSequence-searchStr"><a href="#containsIgnoreCase-CharSequence-str-CharSequence-searchStr" class="headerlink" title="containsIgnoreCase(CharSequence str, CharSequence searchStr)"></a>containsIgnoreCase(CharSequence str, CharSequence searchStr)</h3><p>同<code>contains(CharSequence seq, CharSequence searchSeq)</code>相似，忽略大小写。</p>
<h3 id="containsWhitespace-final-CharSequence-seq"><a href="#containsWhitespace-final-CharSequence-seq" class="headerlink" title="containsWhitespace(final CharSequence seq)"></a>containsWhitespace(final CharSequence seq)</h3><p>是<code>contains(CharSequence seq, CharSequence searchSeq)</code>的特殊情形，判断是否包含空白字符。</p>
<h3 id="containsAny-CharSequence-cs-CharSequence…-searchCharSequences"><a href="#containsAny-CharSequence-cs-CharSequence…-searchCharSequences" class="headerlink" title="containsAny(CharSequence cs, CharSequence… searchCharSequences)"></a>containsAny(CharSequence cs, CharSequence… searchCharSequences)</h3><p>判断某字符串是否包含其后的任意一个字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">containsAny</span><span class="token punctuation">(</span><span class="token string">"abcd"</span><span class="token punctuation">,</span> <span class="token string">"ab"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">containsAny</span><span class="token punctuation">(</span><span class="token string">"abcd"</span><span class="token punctuation">,</span> <span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"cd"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">containsAny</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"d"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">true</span></code></pre>
<h3 id="containsNone-CharSequence-cs-String-invalidChars"><a href="#containsNone-CharSequence-cs-String-invalidChars" class="headerlink" title="containsNone(CharSequence cs, String invalidChars)"></a>containsNone(CharSequence cs, String invalidChars)</h3><p>判断某字符串是否不含其后字符串的任意一个字符。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">containsNone</span><span class="token punctuation">(</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>      <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">containsNone</span><span class="token punctuation">(</span><span class="token string">"abab"</span><span class="token punctuation">,</span> <span class="token string">"xyz"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">containsNone</span><span class="token punctuation">(</span><span class="token string">"ab1"</span><span class="token punctuation">,</span> <span class="token string">"xyz"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">containsNone</span><span class="token punctuation">(</span><span class="token string">"abz"</span><span class="token punctuation">,</span> <span class="token string">"xyz"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h2 id="分割字符串"><a href="#分割字符串" class="headerlink" title="分割字符串"></a>分割字符串</h2><h3 id="split-String-str-String-separatorChars"><a href="#split-String-str-String-separatorChars" class="headerlink" title="split(String str, String separatorChars)"></a>split(String str, String separatorChars)</h3><p>将某字符串按字符分割成数组，默认按空格分组。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"abc def"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"def"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"abc def"</span><span class="token punctuation">,</span> <span class="token string">" "</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"def"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"abc  def"</span><span class="token punctuation">,</span> <span class="token string">" "</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">"def"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"ab:cd:ef"</span><span class="token punctuation">,</span> <span class="token string">":"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"cd"</span><span class="token punctuation">,</span> <span class="token string">"ef"</span><span class="token punctuation">]</span></code></pre>
<h3 id="split-String-str-String-separatorChars-int-max"><a href="#split-String-str-String-separatorChars-int-max" class="headerlink" title="split(String str, String separatorChars, int max)"></a>split(String str, String separatorChars, int max)</h3><p>将某字符串按字符分割成最大max长度的数组，默认按空格分组。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"ab cd ef"</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"cd"</span><span class="token punctuation">,</span> <span class="token string">"ef"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"ab   cd ef"</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"cd"</span><span class="token punctuation">,</span> <span class="token string">"ef"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"ab:cd:ef"</span><span class="token punctuation">,</span> <span class="token string">":"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"cd"</span><span class="token punctuation">,</span> <span class="token string">"ef"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">"ab:cd:ef"</span><span class="token punctuation">,</span> <span class="token string">":"</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"cd:ef"</span><span class="token punctuation">]</span></code></pre>
<h3 id="splitByCharacterType-final-String-str"><a href="#splitByCharacterType-final-String-str" class="headerlink" title="splitByCharacterType(final String str)"></a>splitByCharacterType(final String str)</h3><p>按字符串类型划分字符串为数组。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">splitByCharacterType</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>         <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">splitByCharacterType</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>           <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">splitByCharacterType</span><span class="token punctuation">(</span><span class="token string">"ab de fg"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">" "</span><span class="token punctuation">,</span> <span class="token string">"de"</span><span class="token punctuation">,</span> <span class="token string">" "</span><span class="token punctuation">,</span> <span class="token string">"fg"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">splitByCharacterType</span><span class="token punctuation">(</span><span class="token string">"ab   de fg"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"   "</span><span class="token punctuation">,</span> <span class="token string">"de"</span><span class="token punctuation">,</span> <span class="token string">" "</span><span class="token punctuation">,</span> <span class="token string">"fg"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">splitByCharacterType</span><span class="token punctuation">(</span><span class="token string">"ab:cd:ef"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">":"</span><span class="token punctuation">,</span> <span class="token string">"cd"</span><span class="token punctuation">,</span> <span class="token string">":"</span><span class="token punctuation">,</span> <span class="token string">"ef"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">splitByCharacterType</span><span class="token punctuation">(</span><span class="token string">"number5"</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"number"</span><span class="token punctuation">,</span> <span class="token string">"5"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">splitByCharacterType</span><span class="token punctuation">(</span><span class="token string">"fooBar"</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"foo"</span><span class="token punctuation">,</span> <span class="token string">"B"</span><span class="token punctuation">,</span> <span class="token string">"ar"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">splitByCharacterType</span><span class="token punctuation">(</span><span class="token string">"foo200Bar"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"foo"</span><span class="token punctuation">,</span> <span class="token string">"200"</span><span class="token punctuation">,</span> <span class="token string">"B"</span><span class="token punctuation">,</span> <span class="token string">"ar"</span><span class="token punctuation">]</span>
StringUtils<span class="token punctuation">.</span><span class="token function">splitByCharacterType</span><span class="token punctuation">(</span><span class="token string">"ASFRules"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">"ASFR"</span><span class="token punctuation">,</span> <span class="token string">"ules"</span><span class="token punctuation">]</span></code></pre>
<h2 id="连接字符串"><a href="#连接字符串" class="headerlink" title="连接字符串"></a>连接字符串</h2><h3 id="join-T…-elements"><a href="#join-T…-elements" class="headerlink" title="join(T… elements)"></a>join(T… elements)</h3><p>无连接符连接字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>            <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span>              <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token punctuation">[</span>null<span class="token punctuation">]</span><span class="token punctuation">)</span>          <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">,</span> <span class="token string">"c"</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token punctuation">[</span>null<span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"a"</span></code></pre>
<h3 id="join-Object-array-String-separator"><a href="#join-Object-array-String-separator" class="headerlink" title="join(Object[] array, String separator)"></a>join(Object[] array, String separator)</h3><p>将提供的数组按连接符连成字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token operator">*</span><span class="token punctuation">)</span>               <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token operator">*</span><span class="token punctuation">)</span>                 <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token punctuation">[</span>null<span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token operator">*</span><span class="token punctuation">)</span>             <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">,</span> <span class="token string">"c"</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">';'</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"a;b;c"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"b"</span><span class="token punctuation">,</span> <span class="token string">"c"</span><span class="token punctuation">]</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token punctuation">[</span>null<span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">';'</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">";;a"</span></code></pre>
<h2 id="删除字符串"><a href="#删除字符串" class="headerlink" title="删除字符串"></a>删除字符串</h2><h3 id="deleteWhitespace-String-str"><a href="#deleteWhitespace-String-str" class="headerlink" title="deleteWhitespace(String str)"></a>deleteWhitespace(String str)</h3><p>删除空白字符。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">deleteWhitespace</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>         <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">deleteWhitespace</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>           <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">deleteWhitespace</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token string">"abc"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">deleteWhitespace</span><span class="token punctuation">(</span><span class="token string">"   ab  c  "</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abc"</span></code></pre>
<h3 id="removeStart-String-str-String-remove"><a href="#removeStart-String-str-String-remove" class="headerlink" title="removeStart(String str, String remove)"></a>removeStart(String str, String remove)</h3><p>删除指定字符串前缀的字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">removeStart</span><span class="token punctuation">(</span><span class="token string">"www.domain.com"</span><span class="token punctuation">,</span> <span class="token string">"www."</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"domain.com"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">removeStart</span><span class="token punctuation">(</span><span class="token string">"domain.com"</span><span class="token punctuation">,</span> <span class="token string">"www."</span><span class="token punctuation">)</span>       <span class="token operator">=</span> <span class="token string">"domain.com"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">removeStart</span><span class="token punctuation">(</span><span class="token string">"www.domain.com"</span><span class="token punctuation">,</span> <span class="token string">"domain"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"www.domain.com"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">removeStart</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token string">"abc"</span></code></pre>
<h3 id="removeStartIgnoreCase-String-str-String-remove"><a href="#removeStartIgnoreCase-String-str-String-remove" class="headerlink" title="removeStartIgnoreCase(String str, String remove)"></a>removeStartIgnoreCase(String str, String remove)</h3><p>同<code>removeStart(String str, String remove)</code>相似，忽略大小写。</p>
<h3 id="removeEnd-String-str-String-remove"><a href="#removeEnd-String-str-String-remove" class="headerlink" title="removeEnd(String str, String remove)"></a>removeEnd(String str, String remove)</h3><p>同<code>removeStart(String str, String remove)</code>相反。</p>
<h3 id="removeEndIgnoreCase-String-str-String-remove"><a href="#removeEndIgnoreCase-String-str-String-remove" class="headerlink" title="removeEndIgnoreCase(String str, String remove)"></a>removeEndIgnoreCase(String str, String remove)</h3><p>同<code>removeEnd(String str, String remove)</code>相似，忽略大小写。</p>
<h3 id="remove-String-str-String-remove"><a href="#remove-String-str-String-remove" class="headerlink" title="remove(String str, String remove)"></a>remove(String str, String remove)</h3><p>移除字符串中指定的字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">"queued"</span><span class="token punctuation">,</span> <span class="token string">"ue"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"qd"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">"queued"</span><span class="token punctuation">,</span> <span class="token string">"zz"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"queued"</span></code></pre>
<h3 id="removeIgnoreCase-String-str-String-remove"><a href="#removeIgnoreCase-String-str-String-remove" class="headerlink" title="removeIgnoreCase(String str, String remove)"></a>removeIgnoreCase(String str, String remove)</h3><p>同<code>remove(String str, String remove)</code>相似，忽略大小写。</p>
<h2 id="替换字符串"><a href="#替换字符串" class="headerlink" title="替换字符串"></a>替换字符串</h2><h3 id="replace-String-text-String-searchString-String-replacement"><a href="#replace-String-text-String-searchString-String-replacement" class="headerlink" title="replace(String text, String searchString, String replacement)"></a>replace(String text, String searchString, String replacement)</h3><p>替换某字符串为另一个字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">"aba"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"aba"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">"aba"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token string">"b"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">"aba"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"z"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"zbz"</span></code></pre>
<h3 id="replaceIgnoreCase-String-text-String-searchString-String-replacement"><a href="#replaceIgnoreCase-String-text-String-searchString-String-replacement" class="headerlink" title="replaceIgnoreCase(String text, String searchString, String replacement)"></a>replaceIgnoreCase(String text, String searchString, String replacement)</h3><p>同<code>replace(String text, String searchString, String replacement)</code>相似，忽略大小写。</p>
<h3 id="replace-String-text-String-searchString-String-replacement-int-max"><a href="#replace-String-text-String-searchString-String-replacement-int-max" class="headerlink" title="replace(String text, String searchString, String replacement, int max)"></a>replace(String text, String searchString, String replacement, int max)</h3><p>替换某字符串为另一个字符串,从左到右替换最大max次。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">"abaa"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abaa"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">"abaa"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"b"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">"abaa"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"z"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"abaa"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">"abaa"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"z"</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"zbaa"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">"abaa"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"z"</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"zbza"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token string">"abaa"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token string">"z"</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"zbzz"</span></code></pre>
<h3 id="replaceEach-String-text-String-searchList-String-replacementList"><a href="#replaceEach-String-text-String-searchList-String-replacementList" class="headerlink" title="replaceEach(String text, String[] searchList, String[] replacementList)"></a>replaceEach(String text, String[] searchList, String[] replacementList)</h3><p>替换某些字符串为另一些字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">replaceEach</span><span class="token punctuation">(</span><span class="token string">"aba"</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> null<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"aba"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replaceEach</span><span class="token punctuation">(</span><span class="token string">"aba"</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"aba"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replaceEach</span><span class="token punctuation">(</span><span class="token string">"aba"</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"aba"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replaceEach</span><span class="token punctuation">(</span><span class="token string">"aba"</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token string">"a"</span><span class="token punctuation">}</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"aba"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replaceEach</span><span class="token punctuation">(</span><span class="token string">"aba"</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token string">"a"</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token string">""</span><span class="token punctuation">}</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"b"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replaceEach</span><span class="token punctuation">(</span><span class="token string">"aba"</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span>null<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token string">"a"</span><span class="token punctuation">}</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"aba"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replaceEach</span><span class="token punctuation">(</span><span class="token string">"abcde"</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"d"</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token string">"w"</span><span class="token punctuation">,</span> <span class="token string">"t"</span><span class="token punctuation">}</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"wcte"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">replaceEach</span><span class="token punctuation">(</span><span class="token string">"abcde"</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token string">"d"</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">{</span><span class="token string">"d"</span><span class="token punctuation">,</span> <span class="token string">"t"</span><span class="token punctuation">}</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"dcte"</span></code></pre>
<h2 id="填充字符串"><a href="#填充字符串" class="headerlink" title="填充字符串"></a>填充字符串</h2><h3 id="repeat-final-String-str-final-int-repeat"><a href="#repeat-final-String-str-final-int-repeat" class="headerlink" title="repeat(final String str, final int repeat)"></a>repeat(final String str, final int repeat)</h3><p>生成重复的字符串，repeat代表生成次数。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"aaa"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">"ab"</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abab"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">"a"</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">""</span></code></pre>
<h3 id="repeat-String-str-String-separator-int-repeat"><a href="#repeat-String-str-String-separator-int-repeat" class="headerlink" title="repeat(String str, String separator, int repeat)"></a>repeat(String str, String separator, int repeat)</h3><p>生成重复的字符串，repeat代表生成次数。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">"x"</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>  <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">"x"</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token string">"xxx"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">repeat</span><span class="token punctuation">(</span><span class="token string">"?"</span><span class="token punctuation">,</span> <span class="token string">", "</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"?, ?, ?"</span></code></pre>
<h2 id="字符串计数"><a href="#字符串计数" class="headerlink" title="字符串计数"></a>字符串计数</h2><h3 id="countMatches-CharSequence-str-CharSequence-sub"><a href="#countMatches-CharSequence-str-CharSequence-sub" class="headerlink" title="countMatches(CharSequence str, CharSequence sub)"></a>countMatches(CharSequence str, CharSequence sub)</h3><p>计算某字符串在字符串中的出现次数。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">countMatches</span><span class="token punctuation">(</span><span class="token string">"abba"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">countMatches</span><span class="token punctuation">(</span><span class="token string">"abba"</span><span class="token punctuation">,</span> <span class="token string">""</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token number">0</span>
StringUtils<span class="token punctuation">.</span><span class="token function">countMatches</span><span class="token punctuation">(</span><span class="token string">"abba"</span><span class="token punctuation">,</span> <span class="token string">"a"</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token number">2</span>
StringUtils<span class="token punctuation">.</span><span class="token function">countMatches</span><span class="token punctuation">(</span><span class="token string">"abba"</span><span class="token punctuation">,</span> <span class="token string">"ab"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token number">1</span>
StringUtils<span class="token punctuation">.</span><span class="token function">countMatches</span><span class="token punctuation">(</span><span class="token string">"abba"</span><span class="token punctuation">,</span> <span class="token string">"xxx"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">0</span></code></pre>
<h2 id="字符测试"><a href="#字符测试" class="headerlink" title="字符测试"></a>字符测试</h2><h3 id="isAlpha-CharSequence-cs"><a href="#isAlpha-CharSequence-cs" class="headerlink" title="isAlpha(CharSequence cs)"></a>isAlpha(CharSequence cs)</h3><p>判断字符串是否是Unicode字母。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">isAlpha</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlpha</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlpha</span><span class="token punctuation">(</span><span class="token string">"  "</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlpha</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlpha</span><span class="token punctuation">(</span><span class="token string">"ab2c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlpha</span><span class="token punctuation">(</span><span class="token string">"ab-c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="isAlphaSpace-CharSequence-cs"><a href="#isAlphaSpace-CharSequence-cs" class="headerlink" title="isAlphaSpace(CharSequence cs)"></a>isAlphaSpace(CharSequence cs)</h3><p>同<code>isAlpha(CharSequence cs)</code>相似。判断字符串是否是Unicode字母或空格。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">isAlphaSpace</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlphaSpace</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlphaSpace</span><span class="token punctuation">(</span><span class="token string">"  "</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlphaSpace</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlphaSpace</span><span class="token punctuation">(</span><span class="token string">"ab c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlphaSpace</span><span class="token punctuation">(</span><span class="token string">"ab2c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAlphaSpace</span><span class="token punctuation">(</span><span class="token string">"ab-c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="isAlphanumeric-CharSequence-cs"><a href="#isAlphanumeric-CharSequence-cs" class="headerlink" title="isAlphanumeric(CharSequence cs)"></a>isAlphanumeric(CharSequence cs)</h3><p>同<code>isAlpha(CharSequence cs)</code>相似。判断字符串是否是Unicode字母或数字。</p>
<h3 id="isAlphanumericSpace-CharSequence-cs"><a href="#isAlphanumericSpace-CharSequence-cs" class="headerlink" title="isAlphanumericSpace(CharSequence cs)"></a>isAlphanumericSpace(CharSequence cs)</h3><p>同<code>isAlpha(CharSequence cs)</code>相似。判断字符串是否是Unicode字母、空格或数字。</p>
<h3 id="isNumeric-CharSequence-cs"><a href="#isNumeric-CharSequence-cs" class="headerlink" title="isNumeric(CharSequence cs)"></a>isNumeric(CharSequence cs)</h3><p>判断字符串是否是数字。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">isNumeric</span><span class="token punctuation">(</span><span class="token string">"123"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isNumeric</span><span class="token punctuation">(</span><span class="token string">"12 3"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isNumeric</span><span class="token punctuation">(</span><span class="token string">"ab2c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isNumeric</span><span class="token punctuation">(</span><span class="token string">"12-3"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isNumeric</span><span class="token punctuation">(</span><span class="token string">"12.3"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isNumeric</span><span class="token punctuation">(</span><span class="token string">"-123"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isNumeric</span><span class="token punctuation">(</span><span class="token string">"+123"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="isNumericSpace-CharSequence-cs"><a href="#isNumericSpace-CharSequence-cs" class="headerlink" title="isNumericSpace(CharSequence cs)"></a>isNumericSpace(CharSequence cs)</h3><p>同<code>isNumeric(CharSequence cs)</code>相似。判断字符串是否是空格或数字。</p>
<h3 id="getDigits-String-str"><a href="#getDigits-String-str" class="headerlink" title="getDigits(String str)"></a>getDigits(String str)</h3><p>从字符串中提取出数字为字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">getDigits</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>  <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">getDigits</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">getDigits</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">getDigits</span><span class="token punctuation">(</span><span class="token string">"1000$"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"1000"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">getDigits</span><span class="token punctuation">(</span><span class="token string">"1123~45"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"12345"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">getDigits</span><span class="token punctuation">(</span><span class="token string">"(541) 754-3010"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"5417543010"</span></code></pre>
<h3 id="isWhitespace-CharSequence-cs"><a href="#isWhitespace-CharSequence-cs" class="headerlink" title="isWhitespace(CharSequence cs)"></a>isWhitespace(CharSequence cs)</h3><p>判断是否是空格。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">isWhitespace</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isWhitespace</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isWhitespace</span><span class="token punctuation">(</span><span class="token string">"  "</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isWhitespace</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isWhitespace</span><span class="token punctuation">(</span><span class="token string">"ab2c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isWhitespace</span><span class="token punctuation">(</span><span class="token string">"ab-c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="isAllLowerCase-CharSequence-cs"><a href="#isAllLowerCase-CharSequence-cs" class="headerlink" title="isAllLowerCase(CharSequence cs)"></a>isAllLowerCase(CharSequence cs)</h3><p>判断字符串是否都是小写。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">isAllLowerCase</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllLowerCase</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllLowerCase</span><span class="token punctuation">(</span><span class="token string">"  "</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllLowerCase</span><span class="token punctuation">(</span><span class="token string">"abc"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllLowerCase</span><span class="token punctuation">(</span><span class="token string">"abC"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllLowerCase</span><span class="token punctuation">(</span><span class="token string">"ab c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllLowerCase</span><span class="token punctuation">(</span><span class="token string">"ab1c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">isAllLowerCase</span><span class="token punctuation">(</span><span class="token string">"ab/c"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="isAllUpperCase-CharSequence-cs"><a href="#isAllUpperCase-CharSequence-cs" class="headerlink" title="isAllUpperCase(CharSequence cs)"></a>isAllUpperCase(CharSequence cs)</h3><p>同<code>isAllLowerCase</code>相反。判断字符串是否都是大写。</p>
<h3 id="isMixedCase-CharSequence-cs"><a href="#isMixedCase-CharSequence-cs" class="headerlink" title="isMixedCase(CharSequence cs)"></a>isMixedCase(CharSequence cs)</h3><p>同<code>isAllLowerCase</code>相似。判断字符串是否大小写都有。</p>
<h2 id="默认字符串"><a href="#默认字符串" class="headerlink" title="默认字符串"></a>默认字符串</h2><h3 id="defaultString-String-str"><a href="#defaultString-String-str" class="headerlink" title="defaultString(String str)"></a>defaultString(String str)</h3><p>得到默认字符串，默认空字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">defaultString</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">defaultString</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">defaultString</span><span class="token punctuation">(</span><span class="token string">"bat"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"bat"</span></code></pre>
<h3 id="defaultString-String-str-String-defaultStr"><a href="#defaultString-String-str-String-defaultStr" class="headerlink" title="defaultString(String str, String defaultStr)"></a>defaultString(String str, String defaultStr)</h3><p>如果是null，则得到默认字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">defaultString</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">"NULL"</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"NULL"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">defaultString</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">"NULL"</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">defaultString</span><span class="token punctuation">(</span><span class="token string">"bat"</span><span class="token punctuation">,</span> <span class="token string">"NULL"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"bat"</span></code></pre>
<h3 id="defaultIfEmpty-T-str-T-defaultStr"><a href="#defaultIfEmpty-T-str-T-defaultStr" class="headerlink" title="defaultIfEmpty(T str, T defaultStr)"></a>defaultIfEmpty(T str, T defaultStr)</h3><p>同<code>defaultString(String str, String defaultStr)</code>相似。如果是空字符串，则得到默认字符串。</p>
<h2 id="反转字符串"><a href="#反转字符串" class="headerlink" title="反转字符串"></a>反转字符串</h2><h3 id="reverse-final-String-str"><a href="#reverse-final-String-str" class="headerlink" title="reverse(final String str)"></a>reverse(final String str)</h3><p>反转字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">reverse</span><span class="token punctuation">(</span>null<span class="token punctuation">)</span>  <span class="token operator">=</span> null
StringUtils<span class="token punctuation">.</span><span class="token function">reverse</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">)</span>    <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">reverse</span><span class="token punctuation">(</span><span class="token string">"bat"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"tab"</span></code></pre>
<h2 id="缩写字符串"><a href="#缩写字符串" class="headerlink" title="缩写字符串"></a>缩写字符串</h2><h3 id="abbreviate-String-str-int-maxWidth"><a href="#abbreviate-String-str-int-maxWidth" class="headerlink" title="abbreviate(String str, int maxWidth)"></a>abbreviate(String str, int maxWidth)</h3><p>缩写字符串为最大maxWidth长度的字符串，使用<code>...</code>作为缩写的后缀，maxWidth不能小于等于3。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abc..."</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abcdefg"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"abcdefg"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token string">"a..."</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">=</span> IllegalArgumentException</code></pre>
<h3 id="abbreviate-String-str-String-abbrevMarker-int-maxWidth"><a href="#abbreviate-String-str-String-abbrevMarker-int-maxWidth" class="headerlink" title="abbreviate(String str, String abbrevMarker, int maxWidth)"></a>abbreviate(String str, String abbrevMarker, int maxWidth)</h3><p>缩写字符串为最大maxWidth长度的字符串，使用<code>abbrevMarker</code>作为缩写的后缀，maxWidth不能小于等于<code>abbrevMarker</code>的长度。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">""</span><span class="token punctuation">,</span> <span class="token string">"..."</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span>        <span class="token operator">=</span> <span class="token string">""</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token string">"."</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"abcd."</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token string">"."</span><span class="token punctuation">,</span> <span class="token number">7</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"abcdefg"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token string">"."</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">)</span>   <span class="token operator">=</span> <span class="token string">"abcdefg"</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token string">".."</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"ab.."</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token string">".."</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token string">"a.."</span>
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token string">".."</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>  <span class="token operator">=</span> IllegalArgumentException
StringUtils<span class="token punctuation">.</span><span class="token function">abbreviate</span><span class="token punctuation">(</span><span class="token string">"abcdefg"</span><span class="token punctuation">,</span> <span class="token string">"..."</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">)</span> <span class="token operator">=</span> IllegalArgumentException</code></pre>
<h2 id="字符串钱后缀"><a href="#字符串钱后缀" class="headerlink" title="字符串钱后缀"></a>字符串钱后缀</h2><h3 id="startsWith-CharSequence-str-CharSequence-prefix"><a href="#startsWith-CharSequence-str-CharSequence-prefix" class="headerlink" title="startsWith(CharSequence str, CharSequence prefix)"></a>startsWith(CharSequence str, CharSequence prefix)</h3><p>判断某字符串是否包含有指定前缀的字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> null<span class="token punctuation">)</span>      <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span><span class="token string">"abcdef"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span><span class="token string">"abcdef"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span><span class="token string">"ABCDEF"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="startsWithIgnoreCase-CharSequence-str-CharSequence-prefix"><a href="#startsWithIgnoreCase-CharSequence-str-CharSequence-prefix" class="headerlink" title="startsWithIgnoreCase(CharSequence str, CharSequence prefix)"></a>startsWithIgnoreCase(CharSequence str, CharSequence prefix)</h3><p>同<code>startsWith(CharSequence str, CharSequence prefix)</code>相似。忽略大小写。</p>
<h3 id="startsWithAny-CharSequence-sequence-CharSequence…-searchStrings"><a href="#startsWithAny-CharSequence-sequence-CharSequence…-searchStrings" class="headerlink" title="startsWithAny(CharSequence sequence, CharSequence… searchStrings)"></a>startsWithAny(CharSequence sequence, CharSequence… searchStrings)</h3><p>判断某字符串是否包含有其后任意一个指定前缀的字符串。</p>
<pre class=" language-java"><code class="language-java">StringUtils<span class="token punctuation">.</span><span class="token function">startsWithAny</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> null<span class="token punctuation">)</span>      <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWithAny</span><span class="token punctuation">(</span>null<span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span><span class="token string">"abc"</span><span class="token punctuation">}</span><span class="token punctuation">)</span>  <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWithAny</span><span class="token punctuation">(</span><span class="token string">"abcxyz"</span><span class="token punctuation">,</span> null<span class="token punctuation">)</span>     <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWithAny</span><span class="token punctuation">(</span><span class="token string">"abcxyz"</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span><span class="token string">""</span><span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWithAny</span><span class="token punctuation">(</span><span class="token string">"abcxyz"</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span><span class="token string">"abc"</span><span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWithAny</span><span class="token punctuation">(</span><span class="token string">"abcxyz"</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token punctuation">{</span>null<span class="token punctuation">,</span> <span class="token string">"xyz"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">}</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">true</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWithAny</span><span class="token punctuation">(</span><span class="token string">"abcxyz"</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token string">"xyz"</span><span class="token punctuation">,</span> <span class="token string">"ABCX"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span>
StringUtils<span class="token punctuation">.</span><span class="token function">startsWithAny</span><span class="token punctuation">(</span><span class="token string">"ABCXYZ"</span><span class="token punctuation">,</span> null<span class="token punctuation">,</span> <span class="token string">"xyz"</span><span class="token punctuation">,</span> <span class="token string">"abc"</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token boolean">false</span></code></pre>
<h3 id="endsWith-CharSequence-str-CharSequence-suffix"><a href="#endsWith-CharSequence-str-CharSequence-suffix" class="headerlink" title="endsWith(CharSequence str, CharSequence suffix)"></a>endsWith(CharSequence str, CharSequence suffix)</h3><p>同<code>startsWith(CharSequence str, CharSequence prefix)</code>相反。</p>
<h3 id="endsWithIgnoreCase-CharSequence-str-CharSequence-suffix"><a href="#endsWithIgnoreCase-CharSequence-str-CharSequence-suffix" class="headerlink" title="endsWithIgnoreCase(CharSequence str, CharSequence suffix)"></a>endsWithIgnoreCase(CharSequence str, CharSequence suffix)</h3><p>同<code>startsWithIgnoreCase(CharSequence str, CharSequence prefix)</code>相反。</p>
<h3 id="endsWithAny-CharSequence-sequence-CharSequence…-searchStrings"><a href="#endsWithAny-CharSequence-sequence-CharSequence…-searchStrings" class="headerlink" title="endsWithAny(CharSequence sequence, CharSequence… searchStrings)"></a>endsWithAny(CharSequence sequence, CharSequence… searchStrings)</h3><p>同<code>startsWithAny(CharSequence sequence, CharSequence... searchStrings)</code>相反。</p>

            </div>
            <hr/>

            
            <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.88rem;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-large waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fa fa-close"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone" data-wechat-qrcode-helper="<p>微信里点“发现”->“扫一扫”二维码便可查看分享。</p>"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            <div class="reprint">
                <p>
                    <span class="reprint-tip">
                        <i class="fa fa-exclamation-circle"></i>&nbsp;&nbsp;转载请注明:
                    </span>
                    <a href="https://blinkfox.github.io" class="b-link-green">闪烁之狐</a>
                    <i class="fa fa-angle-right fa-lg fa-fw text-color"></i>
                    <a href="/2018/09/27/hou-duan/java/commons/apache-commons-lang-zhi-stringutils/" class="b-link-green">Apache Commons Lang之StringUtils</a>
                </p>
            </div>
        </div>
    </div>

    
        <link rel="stylesheet" href="/libs/gitalk/gitalk.css">
<link rel="stylesheet" href="/css/my-gitalk.css">

<div class="card gitalk-card" data-aos="fade-up">
    <div id="gitalk-container" class="card-content"></div>
</div>

<script src="/libs/gitalk/gitalk.min.js"></script>
<script>
    let gitalk = new Gitalk({
        clientID: '2e56c9f3a90b6e8fb4f0',
        clientSecret: 'ba491ea79bbff85ec80b88db79e210b474a9cbc8',
        repo: 'blinkfox.github.io',
        owner: 'blinkfox',
        admin: ["blinkfox"],
        id: '2018-09-27T00-19-00',
        distractionFreeMode: false  // Facebook-like distraction free mode
    });

    gitalk.render('gitalk-container');
</script>
    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fa fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2018/09/28/qian-duan/hexo-bo-ke-zhu-ti-zhi-hexo-theme-matery-de-jie-shao/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/9.jpg" class="responsive-img" alt="Hexo博客主题之hexo-theme-matery的介绍">
                        
                        <span class="card-title">Hexo博客主题之hexo-theme-matery的介绍</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">English Document | 演示示例 | QQ交流群:926552981

这是一个采用Material Design和响应式设计的 Hexo 博客主题。

特性
简单漂亮，文章内容美观易读
Material Design 设计
</div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2018-09-28
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/前端/" class="post-category" target="_blank">
                                    前端
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Hexo/" target="_blank">
                        <span class="chip bg-color">Hexo</span>
                    </a>
                    
                    <a href="/tags/hexo-theme-matery/" target="_blank">
                        <span class="chip bg-color">hexo-theme-matery</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fa fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2018/09/25/shu-ju-ku/postgresql-ji-chu-zhi-shi-zheng-li/">
                    <div class="card-image">
                        
                        <img src="http://static.blinkfox.com/hexoblog_20180925_sql.jpg" class="responsive-img" alt="PostgreSQL基础知识整理">
                        
                        <span class="card-title">PostgreSQL基础知识整理</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary">数据库操作DMLCREATE TABLECREATE TABLE语句用于创建数据库中的表。语法是：
CREATE TABLE 表名称 (
列名1 数据类型,
列名2 数据类型,
列名3 数据类型,
....
);
例：
CREATE TAB</div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2018-09-25
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/数据库/" class="post-category" target="_blank">
                                    数据库
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/PostgreSQL/" target="_blank">
                        <span class="chip bg-color">PostgreSQL</span>
                    </a>
                    
                    <a href="/tags/数据库/" target="_blank">
                        <span class="chip bg-color">数据库</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>


    </div>
    <div class="col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="fa fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            // headingsOffset: -205,
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });
    });
</script>
    

</main>


<footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            本站由&copy;<a href="https://blinkfox.github.io/" target="_blank">Blinkfox</a>基于
            <a href="https://hexo.io/" target="_blank">Hexo</a> 的
            <a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">hexo-theme-matery</a>主题搭建.

            
                &nbsp;<i class="fa fa-area-chart"></i>&nbsp;站点总字数:&nbsp;
                <span class="white-color">194.7k</span>
            

            
			
                <br>
                
                <span id="busuanzi_container_site_pv">
                    <i class="fa fa-heart-o"></i>
                    本站总访问量 <span id="busuanzi_value_site_pv" class="white-color"></span>
                </span>
                
                
                <span id="busuanzi_container_site_uv">
                    <i class="fa fa-users"></i>
                    次,&nbsp;访客数 <span id="busuanzi_value_site_uv" class="white-color"></span> 人.
                </span>
                
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/blinkfox/" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fa fa-github"></i>
    </a>



    <a href="mailto:chenjiayin1990@163.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fa fa-envelope-open"></i>
    </a>



    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1181062873" class="tooltipped" data-tooltip="QQ联系我: 1181062873" data-position="top" data-delay="50">
        <i class="fa fa-qq"></i>
    </a>



    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fa fa-rss"></i>
    </a>
</div>
    </div>
</footer>

<div class="progress-bar"></div>


<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fa fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-up"></i>
    </a>
</div>


<script src="/libs/materialize/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
<script src="/js/matery.js"></script>

<!-- Global site tag (gtag.js) - Google Analytics -->



    <script src="/libs/others/clicklove.js"></script>


    <script async src="/libs/others/busuanzi.pure.mini.js"></script>


</body>
</html>